﻿InfoWindow = {};

//当点击命令按钮或菜单时，弹出命令发送窗口
InfoWindow.openCommandWindow = function (command, vehicleId, title, icon, url, plateNo) {
	var commandPath = path;
	if (url.indexOf("?") >= 0)
		url += "&dvcId=" + vehicleId;
	else
		url += "?dvcId=" + vehicleId;
	if (command == "CALL_NOW") {
		//点名
		InfoWindow.open(url, 320, 115, title);
	} else if (command == "TERMINAL_MENU") {
		//信息点播菜单设置
		InfoWindow.open(url, 520, 400, title);
	} else if (command == "TERMINAL_CONFIG") {
		//终端参数配置和查询
		InfoWindow.open(url, 720, 500, title);
	} else if (command == "TERMINAL_TEXT") {
		//文本信息下发 
		InfoWindow.open(url, 620, 300, title);
	} else if (command == "LISTEN_TERMINAL") {
		//发送监听命令
		InfoWindow.open(url, 480, 220, title);
	} else if (command == "TERMINAL_EVENT") {
		//终端事件
		InfoWindow.open(url, 520, 400, title);
	} else if (command == "OVER_SPEED_CONFIG") {
		//终端超速设置
		InfoWindow.open(url, 520, 240, title);
	} else if (command == "TIRED_CONFIG") {
		//终端疲劳驾驶设置
		InfoWindow.open(url, 520, 260, title);
	} else if (command == "SEND_INFORMATION") {
		//信息服务下发
		InfoWindow.open(url, 520, 350, title);
	} else if (command == "MEDIA_UPLOAD") {
		//多媒体上传
		InfoWindow.open(url, 520, 400, title);
	} else if (command == "MEDIA_SEARCH") {
		//多媒体检索
		InfoWindow.open(url, 820, 500, title);
	} else if (command == "AUDIO_RECORDER") {
		//录音
		InfoWindow.open(url, 520, 320, title);
	} else if (command == "PHONE_BOOK") {
		//设置电话本
		InfoWindow.open(url, 820, 400, title);
	} else if (command == "TAKE_PICTURE") {
		//拍照
		InfoWindow.open(url, 600, 520, title);
	} else if (command == "SEND_QUESTION") {
		//提问下发
		InfoWindow.open(url, 520, 400, title);
	} else if (command == "TEMP_TRACK") {
		//临时位置跟踪
		InfoWindow.open(url, 520, 250, title);
	} else if (command == "TERMINAL_ENCLOSURE") {
		//围栏下发窗口
		InfoWindow.open1(url, 820, 500, title);
	} else if (command == "TERMINAL_ROUTE") {
		//配置线路
		InfoWindow.open(url, 820, 550, title);
	}
	else if (command == "VEHICLE_RECORDER") {
		//行驶记录仪下发窗口
		InfoWindow.open(url, 820, 580, title);
	} else if (command == "VEHICLE_RECORDER_2012") {
		//行驶记录仪下发窗口
		InfoWindow.open(url, 820, 580, title);
	} else if (command == "PLATFORM_COMMAND") {
		//809平台命令下发窗口
		InfoWindow.open(url, 520, 370, title);
	} else if (command == "WIRELESS_UPDATE") {
		//无线升级窗口
		InfoWindow.open(url, 520, 570, title);
	} else if (command == "CONTROL_TERMINAL") {
		//终端控制窗口
		InfoWindow.open(url, 320, 190, title);
	} else if (command == "TRANSPARENT_SEND") {
		//透明传输命令下发窗口
		InfoWindow.open(url, 520, 350, title);
	} else if (command == "DOOR_CONTROL") {
		//车辆控制 门控制
		InfoWindow.open(url, 520, 180, title);
	}
	else if (command == "REAL_MONITOR") {
		//单独监控
		var url = path + "?dvcId=" + vehicleId;
		addTab(title, url, icon);
	} else if (command == "VEHICLE_INFO") {
		InfoWindow.open(url, 720, 450, title);
	} else if (command == "HISTORY_ROUTE") {
		title = '历史轨迹';
		var url = path + "/map/hisroute?dvcId=" + vehicleId + "&dvcSim=" + plateNo;
		var item = {name: url, text: title}
		addTab(item);
	} else if (command == "BIND_VEHICLE") {
		InfoWindow.open(url, 820, 550, title);
	}
	else if (command == "SHORT_MESSAGE") {
		//短报文
		InfoWindow.open(url, 520, 200, title);
	}
}

/**
 * 在弹出窗口的基础上继续弹出子窗口
 */
InfoWindow.openChildWindow = function (url, width, height, title, option) {

	newoption = "width = " + width + ",height=" + height + ",left=" + (window.screen.width - width) / 2 + ",scrollbars=yes,location=no,top=" + (window.screen.height - height) / 2;
	if (option != null || option != "") {
		newoption += "," + option;
	}

	var w = window.open(url, "newwindow", newoption);
	w.focus();
}

InfoWindow.open = function (url, width, height, title, option) {

	if (!title)
		title = "编辑窗口";
	openIFrameWindow(url, width, height, title);
	return;

}

InfoWindow.open1 = function (url, width, height, title, option) {

	if (!title)
		title = "编辑窗口";
	openIFrameWindow1(url, width, height, title);
	return;

}
